package com.yungam.imcs.controller.process_config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yungam.common.bean.process.ProductProcess;
import com.yungam.common.response.RetDTO;
import com.yungam.common.service.ProductProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "工序配置接口")
@RestController
@RequestMapping("/processConfig")
public class ProcessConfigController {

    @Resource
    private ProductProcessService productProcessService;

    @ApiOperation("查询工序信息")
    @GetMapping("/data")
    public RetDTO<?> getProcessData(@ApiParam("产品号") @RequestParam(required = true) String productNo) {
        List<ProductProcess> list = productProcessService.list(new QueryWrapper<ProductProcess>()
                .eq("product_no", productNo));
        return RetDTO.data(list);
    }

    @ApiOperation("保存加工检验工序信息")
    @PostMapping("/saveExtra")
    public RetDTO<?> saveExtra(@ApiParam("产品工序集合") @RequestBody List<ProductProcess> data) {
        productProcessService.updateBatchById(data);
        return RetDTO.success();
    }

}
